using System.Web.Mvc;
using IGMVC.Web.Models;

namespace IGMVC.Web.Controllers
{
    public class IssueTypesController : Controller
    {
        private IssueTypeRepository _issueTypes;

        public IssueTypesController()
        {
            this._issueTypes = new IssueTypeRepository();
        }

        public ActionResult Index()
        {
            var vm = new IssueTypeListView();
            vm.IssueTypes = this._issueTypes.GetAll();
            return View("Index", vm);
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Persist(IssueType type)
        {
            this._issueTypes.Persist(type);
            return RedirectToAction("Index");
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Delete(int id)
        {
            this._issueTypes.Delete(id);
            return RedirectToAction("Index");
        }
    }
}
